#include "SimpleEngine/Graphics.hpp"
#include <iostream>

int main(){
	se::System::trace->Ready();
	sf::RenderWindow window(sf::VideoMode(500,500),"Test");
	se::Graphics::GraphicThread g;
	g.SetRenderWindow(window);
	se::ContentFile cf("data/test.txt");
	{
		se::Graphics::DrawableDataPool dataPool(cf, 0);
		se::Graphics::AnimatedSprite Sprite1(dataPool);
		se::Graphics::AnimatedSprite Sprite2(dataPool);
		std::cout<<"before"<<std::endl;
		Sprite1.SetAnim("ani1");
		Sprite2.SetAnim("l");
		std::cout<<"after"<<std::endl;

		//Sprite1.m_animChrono.Restart();
		//Sprite2.m_animChrono.Restart();
		window.setActive(false);
		g.Start();
		while (window.isOpen())
		{
			sf::Event Event;
			while(window.pollEvent(Event))
			{
				if (Event.type == sf::Event::Closed){
				g.RequestInterruption();
				g.Join();
				window.close();
				return 0;
				}
				if(Event.type == sf::Event::MouseButtonPressed){
					if(Event.mouseButton.button == sf::Mouse::Left){
						/*if(Sprite1.m_animChrono.IsPaused()){
							Sprite1.m_animChrono.Resume();
						}else{
							Sprite1.m_animChrono.Pause();
						}*/
					}else if(Event.mouseButton.button == sf::Mouse::Right){
						//Sprite1.m_animChrono.Restart();
					}
				}
			}
			
			//std::cout << Sprite.GetSubRect().Left<<":"<< Sprite.GetSubRect().Right<<":"<< Sprite.GetSubRect().Top<<":"<< Sprite.GetSubRect().Bottom<<":"<<std::endl;
			Sprite1.setPosition(100.f,100.f);
			Sprite1.setScale(2.f,2.f);
			
			Sprite2.setPosition(300.f,400.f);
			Sprite2.setScale(3.f,5.f);
			se::System::time->Update();
			g.Push(Sprite1);
			g.Push(Sprite2);
			g.Swap();
		}
	}
	std::cout<<"lol"<<std::endl;
}
